<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var ispalindrome = function(x){
        //    将数字转换为字符串类型
            var str = String(x);
            console.log(str.length)
            // 负数不是回文数
            if(x>=0){
                // 遍历字符串前半部分
                for(var i = 0;i<str.length/2;i++)
                {
                    // 判断头尾是否相等
                    if(str[i]!=str[str.length-i-1]){
                       return false;
                    }
                }
                return true;
            }
            else{
                return false;
            }
        }
        var res=ispalindrome(10);
        console.log(res)
    </script>
</body>
</html>